package com.smi.service;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;

/**
 * Created by yesiming on 2017/6/12.
 */
public interface Generate {

    default ResultSet getResult(String tableName, String dbName) {
        Connection conn = null;

        try {
            Class.forName("com.mysql.jdbc.Driver");
            conn = DriverManager.getConnection(String.format(Memory.URL, dbName));
            //Statement stmt = conn.createStatement();
            String sql = "select COLUMN_NAME, COLUMN_TYPE from information_schema.COLUMNS where table_name = ? and table_schema = ?;";
            PreparedStatement pStat = conn.prepareStatement(sql);
            pStat.setString(1, tableName);
            pStat.setString(2, dbName);
            ResultSet rs = pStat.executeQuery();
            return rs;
        } catch (Exception e) {
            e.printStackTrace();
        }

        return null;
    }
}
